import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import { list } from './SysDataRule.api';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '设备一级分类',
    align: 'center',
    dataIndex: 'deviceMark',
  },
  {
    title: '设备二级分类',
    align: 'center',
    dataIndex: 'deviceCla',
  },
  {
    title: '设备三级级分类',
    align: 'center',
    dataIndex: 'deviceCategory',
  },
  {
    title: '规则绑定',
    align: 'center',
    dataIndex: 'ruleDetail',
  },
  {
    title: '需要处理字段',
    align: 'center',
    dataIndex: 'needField',
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'flag',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '设备一级分类',
    field: 'deviceMark',
    component: 'Input',
    //colProps: {span: 6},
    dynamicDisabled: true, // 设置为禁用
  },
  {
    label: '设备二级分类',
    field: 'deviceCla',
    component: 'Input',
    //colProps: {span: 6},
    dynamicDisabled: true, // 设置为禁用
  },
  {
    label: '设备三级级分类',
    field: 'deviceCategory',
    component: 'Input',
    //colProps: {span: 6},
    dynamicDisabled: true, // 设置为禁用
  },
  {
    label: '需要处理字段',
    field: 'needField',
    component: 'Input',
    //colProps: {span: 6},
    dynamicDisabled: true, // 设置为禁用
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '设备一级分类',
    field: 'deviceMark',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '设备二级分类',
    field: 'deviceCla',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '设备三级级分类',
    field: 'deviceCategory',
    component: 'Input',
    dynamicDisabled: true,
  },

  {
    label: '需要处理字段',
    field: 'needField',
    component: 'Input',
    dynamicDisabled: true,
  },

  {
    label: '规则绑定',
    field: 'ruleDetail',
    component: 'ApiSelect', // 改为API下拉组件
    componentProps: {
      // 配置接口和字段映射
      api: list, // 使用SysDataRuleList的列表接口
      resultField: 'records',
      labelField: 'ruleDetail',
      valueField: 'ruleDetail',
      params: { field: 'id,ruleDetail' },
      showSearch: true,
    },
  },
  // 新增隐藏的deviceId字段
  {
    field: 'deviceId',
    component: 'Input',
    show: false,
  },
  {
    field: 'agreementId',
    component: 'Input',
    show: false,
  },
  {
    field: 'ruleId',
    component: 'Input',
    show: false,
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
/* agreementId: "123456"
deviceCategory: "设备1"
deviceCla: "123456"
deviceMark: "2"
needField: "param5"
ruleDetail:"对对对"
ruleI: "1950458584466731010" */
// 高级查询数据
export const superQuerySchema = {
  deviceMark: { title: '设备一级分类', order: 0, view: 'text', type: 'string' },
  deviceCla: { title: '设备二级分类', order: 1, view: 'text', type: 'string' },
  deviceCategory: { title: '设备三级级分类', order: 2, view: 'text', type: 'string' },
  ruleDetail: { title: '规则绑定', order: 3, view: 'text', type: 'string' },
  needField: { title: '需要处理字段', order: 4, view: 'text', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
